package 周赛;

public class 银行中激光束数量 {
    public static void main(String[] args) {
      String[]  bank = {"011001","000000","010100","001000"};
        System.out.println(numberOfBeams(bank));
    }
    public static int numberOfBeams(String[] bank) {
         int res = 0,up=0,down=0;
        for (int i = 0; i < bank.length; i++) {
            if (oneNum(bank[i])==0)
                continue;
            if (up==0)
                up = oneNum(bank[i]);
            else if (up!=0 && down==0){
                down = oneNum(bank[i]);
                res += down * up;
                up = down;
                down = 0;
            }
        }
        return res;
    }
    //统计一个字符串中1的数量
    public static int oneNum(String s){
        int num = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i)=='1')
                num++;
        }
        return num;
    }
}
